﻿Imports System.Data.SqlClient

Public Class frmJobOffers

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Dim a As New frmJobOfferNew
        a.ShowDialog()

        FillJobOffers()
    End Sub

    Private Sub frmJobOffers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized

        FillJobOffers()
    End Sub

    Sub FillJobOffers()

        Try
            Me.Cursor = Cursors.WaitCursor

            Dim cmd As New SqlCommand("Select * From JobOffers", cnn)
            Dim reader As SqlDataReader

            Me.GridJobOffers.Rows.Clear()

            cnn.Open()
            reader = cmd.ExecuteReader
            While reader.Read
                Me.GridJobOffers.Rows.Add({reader("SNo"), reader("EmpName"), reader("JobTitle"), _
                                           reader("Branch"), reader("CreatedBy"), CDate(reader.Item("CreatedOn")).ToString("yyyy/MM/dd")})
            End While
            cnn.Close()

            Me.Cursor = Cursors.Default
        Catch ex As Exception
            Me.Cursor = Cursors.Default
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles GridJobOffers.CellContentClick
        If e.ColumnIndex = DGVShow.Index Then
            PrintJobOffer(GridJobOffers.Rows(e.RowIndex).Cells(DGColSNo.Name).Value())
        End If
    End Sub
End Class